Blog

New BoxLang Fix: BoxLang BIFs Return Data

Maria Jose Herrera August 08, 2024

Spread the word

Maria Jose Herrera

August 08, 2024

Spread the word


Share your thoughts

Fixing the Array/Struct BIFs That Return ‘True’ for no reason

We’ve got an exciting update for you! In our upcoming beta release, we’re tackling an issue with certain Built-In Functions (BIFs) that return true instead of the original data structure. This change will make chaining operations easier and more intuitive.

Review Original Post

What’s Changing?

Some of the BIFs in CFML return a boolean, which can be confusing and limit their usability. For instance:

myArr.append("foo") // returns myArr
arrayAppend(myArr) // returns true??

In BoxLang, we’re updating these functions so they return the modified data structure instead. Here’s the list of BIFs that will now return the original data structure:

  • arrayAppend()
  • arrayClear()
  • arrayDeleteAt()
  • arrayInsertAt()
  • arrayResize()
  • arraySet()
  • arraySwap()
  • StructClear()
  • StructKeyTranslate()
  • StructInsert()
  • structAppend()
  • QuerySetRow()
  • QueryDeleteRow()
  • QuerySort()
  • ArrayPrepend()
  • arrayDelete()
  • structDelete()

Legacy CF Code Compatibility

Running legacy CF code on BoxLang? No worries! Our transpiler has been updated to handle this. If the return value of a BIF is being used, the transpiler will automatically wrap it in an Immediately Invoked Function Expression (IIFE) that returns true for CF compatibility—except for arrayDelete() and structDelete(), which will maintain their ability to return true or false as originally intended.

BoxLang Ticket

Examples

With the update, you can now chain BIFs more naturally. For example:

Before:

array = [1, 2, 3];
result = arrayAppend(array, 4); // returns true, not the array

After:

array = [1, 2, 3];
result = arrayAppend(array, 4).arrayInsertAt(1, 0).arrayResize(10);
// Returns the modified array, making chaining possible

BIFs That Stay the Same

Some BIFs will remain unchanged because they return something other than the original data structure for a good reason:

  • queryAddColumn() – returns the index of the column removed
  • queryAddRow() – returns the row number added

For QueryDeleteColumn(), we’ll follow Adobe’s behavior and return the query, matching Adobe’s approach rather than Lucee’s array of removed data.

Try BoxLang

Conditional Return Values

These BIFs have the ability to return true or false, and we’ll preserve their original behavior:

  • arrayDelete() – returns true if the array size decreases after the delete operation
  • structDelete() – returns true if indicateNotExisting is set to true and the key existed before deletion

Visualizing the Changes

Here’s how the transpiler works: If you have CF code like this:

result = arrayPrepend(arr, "foo")

It transpiles to BoxLang code:

result = (arg1, arg2) -> {
	arrayPrepend(arg1, arg2);
	return true;
}(arr, "foo");

However, if the result is not assigned to a variable, used as an argument, or included in a flow control statement, it remains unchanged.

More Information

We’re excited about these improvements and hope they make your BoxLang experience smoother and more powerful. Stay tuned for the beta release and enjoy the enhanced functionality!

For further details, check out the ticket

BoxLang Ticket

Add Your Comment

Recent Entries

Ortus Solutions Brings Innovation with BoxLang as Platinum Sponsor and Keynote Presenter at CFCamp 2025!

Ortus Solutions Brings Innovation with BoxLang as Platinum Sponsor and Keynote Presenter at CFCamp 2025!

Join us for groundbreaking workshops and discover the future of modern development with BoxLang.

Ortus Solutions is thrilled to announce its participation as a Platinum Sponsor and Keynote Presenter at CFCamp 2025, the premier conference for modern web development! Held at the Atomis Hotel Munich Airport by Mercure in Oberding, Germany, on May 22–23, 2025, this event is a must-attend for developers and tech enthusiasts.

As the...

Cristobal Escobar
Cristobal Escobar
December 03, 2024
BoxLang Monthly Newsletter - November Recap 2024

BoxLang Monthly Newsletter - November Recap 2024

This month, we’re excited to share the latest developments, updates, and opportunities from the BoxLang ecosystem. From groundbreaking beta releases to insightful new tools and community highlights, there’s something for every modern web developer.

Dive into our November Recap to explore how BoxLang is shaping the future of web development and discover ways to get involved. Don’t miss exclusive content, upcoming events, and special offers designed to keep you ahead of the curve in the JVM ecosystem.

Maria Jose Herrera
Maria Jose Herrera
December 02, 2024
How a ColdFusion Security Audit Can Protect Your Business from Data Breaches

How a ColdFusion Security Audit Can Protect Your Business from Data Breaches

In today’s digital landscape, security threats are evolving at an alarming rate, and your business’s ColdFusion application—whether powered by Lucee or Adobe ColdFusion—may be more vulnerable than you think. A comprehensive ColdFusion security audit is essential to safeguarding sensitive data, maintaining compliance, and protecting your organization from potential cyberattacks.

Why is a ColdFusion Security Audit Critical?

Security should be a top priority for any business oper...

Cristobal Escobar
Cristobal Escobar
December 02, 2024